<html>

<head><title>Page</title></head>
<body>
  <h1>post message test page</h1>
</body>

<script>
  let numMessages = 0;
  window.addEventListener('message', e => {

    numMessages++;
    document.title = `postMessage: ${numMessages}`;

    e.ports[0].postMessage(`message: ${e.data}, source: ${e.origin}`);

    if (e.data.includes('delayed')) {
        setTimeout(() => e.ports[0].postMessage(`message: ${e.data}2, source: ${e.origin}`), 1000);
        setTimeout(() => e.ports[0].postMessage(`message: ${e.data}3, source: ${e.origin}`), 2000);
    }
  });

</script>
</html>
